package com.appkubes.mall.restful.application.store.controller;

import com.appkubes.common.Response;
import com.appkubes.mall.core.controller.BaseMallStoreController;
import com.appkubes.mall.core.entity.MallStore;
import com.appkubes.mall.restful.application.store.entity.vo.ApplyStoreVO;
import com.appkubes.mall.restful.application.store.entity.vo.StoreInfoVO;
import com.appkubes.mall.restful.application.store.service.StoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Api(tags = "门店管理")
@RestController
@RequestMapping("/store")
public class StoreController extends BaseMallStoreController {

    @Resource
    StoreService storeService;

    @ApiOperation("申请门店(当前允许用户申请多个门店)")
    @PostMapping("/apply")
    public Response apply(@RequestBody ApplyStoreVO applyStoreVO) {
        Boolean flag = storeService.add(applyStoreVO);
        return Response.success(flag);
    }

    @ApiOperation("获取门店信息")
    @PostMapping("/getInfo")
    public Response getInfo(StoreInfoVO storeInfoVO) {
        List<MallStore> mallStore = storeService.getUserStore(storeInfoVO);
        return Response.success(mallStore);
    }


}
